package com.bjpowernode.dataservice.service;

import com.bjpowernode.api.dto.PlatformInfo;
import com.bjpowernode.api.serivce.PlatformService;
import com.bjpowernode.dataservice.mapper.BidInfoMapper;
import com.bjpowernode.dataservice.mapper.ProductMapper;
import com.bjpowernode.dataservice.mapper.UsersMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * @author 麦翔盛
 * @ClassName: PlatformServiceImpl
 * @Package: com.bjpowernode.dataservice.service
 * @description:
 * @date 2022/5/14 21:01
 */

@DubboService(interfaceClass = PlatformService.class,version = "1.0")
@Service
public class PlatformServiceImpl implements PlatformService {
    @Resource
    private UsersMapper usersMapper;

    @Resource
    private ProductMapper productMapper;

    @Resource
    private BidInfoMapper bidInfoMapper;

    @Override
    public PlatformInfo staticsPlatformDateItems() {
        int registerUserCount = usersMapper.getRegisterUserCount();
        BigDecimal averageRate = productMapper.getAverageRate();
        BigDecimal bidMoney = bidInfoMapper.getAllByBidMoney();

        return new PlatformInfo(registerUserCount,averageRate,bidMoney);
    }
}
